package com.design.behavior.visitor.atguigu;

import java.util.LinkedList;
import java.util.List;

/**
 * @ProjectName: design
 * @Package: com.design.behavior.visitor.atguigu
 * @ClassName: ObjectStructure
 * @Author: shenaiguo
 * @Description:
 * @Date: 2020/11/15 0015 11:06
 */
// 步骤4
public class ObjectStructure {

    //维护了一个集合
    private List<Person> persons = new LinkedList<>();

    //增加到 list
    public void attach(Person p) {
        persons.add(p);
    }
    //移除
    public void detach(Person p) { persons.remove(p);
    }

    //显示测评情况
    public void display(Action action) { for(Person p: persons) {
        p.accept(action);
    }

    }
}
